<template>
  <div>
    <c-title :hide="false" :text="diy_name"></c-title>
    <header class="header">
      <div class="header-content">
        <img :src="member.avatar_image" alt="" />
        <div class="flex column left">
          <span class="header-nickname">{{member.nickname}}</span>
          <span class="header-infoId">ID:{{member.uid}}</span>
        </div>
      </div>
    </header>
    <main class="main">
      <ul>
        <li @click="to('lawyerOrder')">
          <div class="item">
            <i class="iconfont icon-fontclass-jilu3"></i>
          </div>
          <span>我的订单</span>
        </li>
        <li @click="to('chatWindow')">
          <div class="item"><i class="iconfont icon-fontclass-pinglun1"></i></div>
          <span>消息</span>
        </li>
        <li @click="to('lawOffice')">
          <div class="item">
            <i class="iconfont icon-fontclass-shouce"></i>
          </div>
          <span>{{ is_lawyer_firm ? "律所管理" : "律所申请" }}</span>
        </li>
        <li @click="to('lawYerManagement')">
          <div class="item"><i class="iconfont icon-fontclass-daili"></i></div>
          <span>{{ is_lawyer ? "律师管理" : "律师申请" }}</span>
        </li>
        <li @click="to('enterprise')">
          <div class="item">
            <i class="iconfont icon-fontclass-qiyeguanli"></i>
          </div>
          <span>企业管理</span>
        </li>
        <li @click="to('operators')" v-if="is_merchant">
          <div class="item">
            <i class="iconfont icon-fontclass-gaikuang"></i>
          </div>
          <span>运营商</span>
        </li>
      </ul>
    </main>
  </div>
</template>

<script>
export default {
  data() {
    return {
      is_lawyer: false,
      is_lawyer_firm: false,
      is_merchant: false,
      diy_name:"",
      set: {},
      member:{}
    };
  },
  mounted() {
      this.getData();
  },
  methods: {
    to(name) {
      if (name == "lawYerManagement" && !this.is_lawyer) {
        this.$router.push(this.fun.getUrl("lawyerPlatformApplyFor",
         {
            l_status:this.set.l_status,
            l_content:this.set.l_content,
            l_top_thumb_image:this.set.l_top_thumb_image
         },
         { apply_for: "lawYerManagement" })); //律师
      } else if (name == "lawOffice" && !this.is_lawyer_firm) {
        this.$router.push(this.fun.getUrl("lawyerPlatformApplyFor",   {
            l_status:this.set.lf_status,
            l_content:this.set.lf_content,
            l_top_thumb_image:this.set.lf_top_thumb_image
         },{ apply_for: "lawOffice" })); //律所
      }else if(name == 'lawyerOrder'){
        this.$router.push(this.fun.getUrl("lawyerOrder",{},{order_type:'member'}))
      }else if(name == 'chatWindow'){
          this.$router.push(this.fun.getUrl("lawyerChart",{},{message_type:1}))
      }else {
        this.$router.push(this.fun.getUrl(name));
      }
    },
     getData() {
      $http.get("plugin.lawyer-platform.frontend.controllers.index.index").then(res => {
        if (res.result == 1) {
          this.is_lawyer = res.data.is_lawyer;
          this.is_lawyer_firm = res.data.is_lawyer_firm;
          this.is_merchant = res.data.is_merchant;
          if (res.data.set) {
            this.set = {
              lf_status: res.data.set.lf_status,
              l_status: res.data.set.l_status,
              lf_content: res.data.set.lf_content,
              l_content: res.data.set.l_content,
              lf_top_thumb_image: res.data.set.lf_top_thumb_image,
              l_top_thumb_image: res.data.set.l_top_thumb_image
            };
            this.member = res.data.member || {};
            this.diy_name = res.data.set.diy_name || "律师平台";
            this.fun.setWXTitle(this.diy_name)
          }
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.flex {
  display: flex;
}

.column {
  flex-direction: column;
}

.left {
  text-align: left;
}

.main {
  margin: 0.714rem;
  background-color: #fff;
  padding-top: 1.4285rem;
}

ul {
  display: flex;
  flex-wrap: wrap;

  li {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 1rem 1.571rem;
  }
}

div.item {
  width: 3rem;
  height: 3rem;
  line-height: 3rem;
  border-radius: 100px;
  background-color: #fdf1cf;
  margin-bottom: 0.785rem;
}

.iconfont {
  color: #daa032;
  font-size: 1.571rem;
}

.header {
  height: 7rem;
  background-image: linear-gradient(0deg, #d5a74f 0%, #f8e088 100%);

  &-content {
    height: inherit;
    display: flex;
    align-items: center;
    padding-left: 1.4285rem;
  }

  img {
    margin: 0;
    width: 3rem;
    height: 3rem;
    border-radius: 100px;
    object-fit: cover;
    border: 1px solid #fff;
    margin-right: 0.6428rem;
  }

  &-nickname {
    color: #845002;
    font-size: 1.142rem;
    line-height: 2.0714rem;
    font-weight: 800;
  }

  &-infoId {
    color: #874f02;
    font-size: 0.857rem;
    line-height: 1.5714rem;
  }
}
</style>
